package com.hst.capacity.infra.convertor;

import com.hst.capacity.domain.common.constants.Constants;
import com.hst.capacity.domain.model.entity.marketing.coupon.CouponRuleInfoEntity;
import com.hst.capacity.domain.model.entity.marketing.promotion.PromotionEntity;
import com.hst.capacity.domain.model.request.marketing.coupon.CouponRuleParam;
import com.hst.capacity.domain.model.request.marketing.promotion.PromotionParam;
import com.hst.capacity.domain.model.response.marketing.promotion.PromotionVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface MarketConvertor {

    MarketConvertor INSTANCE = Mappers.getMapper(MarketConvertor.class);

    @Mapping(target = "effectiveTime",dateFormat = Constants.DATE_FORMAT)
    @Mapping(target = "expiredTime",dateFormat = Constants.DATE_FORMAT)
    PromotionEntity convert(PromotionParam param);

    CouponRuleInfoEntity convert(CouponRuleParam param);


    @Mapping(target = "effectiveTime",dateFormat = Constants.DATE_FORMAT)
    @Mapping(target = "expiredTime",dateFormat = Constants.DATE_FORMAT)
    PromotionVO convert2VO(PromotionEntity entity);

    @Mapping(target = "effectiveTime",dateFormat = Constants.DATE_FORMAT)
    @Mapping(target = "expiredTime",dateFormat = Constants.DATE_FORMAT)
    List<PromotionVO> convert2LstVO(List<PromotionEntity> entity);

}
